package UILayer;
import ControlLayer.*;
import java.util.Scanner;

/**
 * UI of the item and stock functions.
 * 
 * @author Group1
 * @version 2011-06-05
 */
public class ItemUI
{
    // instance variables - replace the example below with your own
    private Scanner reader;
    private ItemController itemController;
    private String nameOfCreatedSupplier;
    private String loginName;
    
    /**
     * Creates the itemUI.
     * @param loginName The loginName is recieved from the LoginUI and is used to decide
     * accesslevel
     */
    public ItemUI(String loginName)
    {
        nameOfCreatedSupplier = "";
        itemController = new ItemController();
        reader = new Scanner(System.in);
        this.loginName = loginName;
        start();
    }
    
    /**
     * Prints the menu on the screen.
     */
    private void writeMenu()
    {
        System.out.println("\f*** Item/Stock Menu ***");
        System.out.println("(1)  Create new item");
        System.out.println("(2)  Find item by barcode and show information");
        System.out.println("(3)  Find item by itemnumber and show information");
        System.out.println("(4)  Update item");
        System.out.println("(5)  Delete item");
        System.out.println("(6)  List of items");
        System.out.println("(7)  List of items which have been ordered/have to be ordered");
        System.out.println("(8)  Update stock with new delivery");
        System.out.println("");
        System.out.println("(0)  Return to MainMenu");
        System.out.println("");
        System.out.print("make choise: ");
    }
    
    /**
     * Loops until the user chose an option.
     */
    public void start()
    {
        boolean stop = false;
        while(!stop) {
            writeMenu();
            int i = UIInput.inputInt();
            if(i == 1) 
            {
                System.out.println("\f- Create Item -");
                createItem();
            }
            if(i == 2) 
            {
                System.out.println("\f- Find item by barcode -");
                findItemByBarcode();
            }
            if(i == 3) 
            {
                System.out.println("\f- Find item by itemnumber -");
                findItemByItemNumber();
            }
            if(i == 4) 
            {
                System.out.println("\f- Update item -");
                updateItem();
            }
            if(i == 5) 
            {
                System.out.println("\f- Delete item -");
                deleteItem();
            }
            if(i == 6) 
            {
                System.out.println("\f- Lists with items -");
                listOfItems();
            }
            if(i == 7) 
            {
                System.out.println("\f- Items which have been ordered/have to be ordered -");
                itemsToOrderBySupplier();
            }
            if(i == 8) 
            {
                System.out.println("\f- Update stock with new delivery from supplier -");
                updateStockNewDelivery();
            }
            if(i == 0) 
            {
                stop = true;
            }
        }
        
    }
    
    /**
     * Creates item.
     */
    private void createItem()
    {
        if(!loginName.equals("manager"))
        {
            System.out.println("You dont have the rigths to do this!");
            back();
        }
        else
        {
            System.out.print("Enter barcode: ");
            String barcode = reader.nextLine();
        
            if(itemController.findItemByBarcode(barcode) != null)
            {
                System.out.println("Barcode exist already!");
                back();
            }
            else
            {
                System.out.print("Enter item number: ");
                String itemNumber = reader.nextLine();
        
                System.out.print("Enter name: ");
                String name = reader.nextLine();
            
                System.out.print("Enter description: ");
                String description = reader.nextLine();
        
                System.out.print("Enter buying price: ");
                int buyingPrice = UIInput.inputInt();
        
                System.out.print("Enter selling price: ");
                int sellingPrice = UIInput.inputInt();
        
                System.out.print("Enter location number. | 1: Byggecenter 2: Traelast 3: Both |: ");
                int locationNumberInt = UIInput.inputInt();
                if(locationNumberInt > 3 || locationNumberInt == 0)
                {
                    boolean ok = false;
                    while(!ok)
                    {
                        System.out.println("Wrong input, try again");
                        System.out.print("Enter location number. | 1: Byggecenter 2: Traelast 3: Both |: ");
                        int locationNumberInt2 = UIInput.inputInt();
                        if(locationNumberInt2 == 1 || locationNumberInt2 == 2 || locationNumberInt2 == 3)
                        {
                            locationNumberInt = locationNumberInt2;
                            ok = true;
                        }
                    }
                }
                
                String locationNumber = "";
                if(locationNumberInt == 1)
                {
                    locationNumber = "Byggecenter";
                }
                if(locationNumberInt == 2)
                {
                    locationNumber = "Traelast";
                }
                if(locationNumberInt == 3)
                {
                    locationNumber = "Byggecenter og traelast";
                }

                System.out.print("Enter amount in stock: ");
                int amountInStock = UIInput.inputInt();
                
                System.out.print("Enter amount pr Order: ");
                int amountPrOrder = UIInput.inputInt();
            
                System.out.print("Enter minimum in stock: ");
                int minStock = UIInput.inputInt();
            
                System.out.print("Enter maximum in stock: ");
                int maxStock = UIInput.inputInt();
        
                System.out.print("Enter supplier: ");
                String supplier = reader.nextLine();
            
                if(itemController.addSupplier(supplier) != null)
                {
                    itemController.createItem(barcode, itemNumber, name, amountPrOrder, description, buyingPrice, sellingPrice, 
                                               locationNumber, itemController.addSupplier(supplier), amountInStock, minStock, maxStock);
                    System.out.println("Item created" + " - (" + name + ")");
                    back();
                }
                else
                {
                    System.out.println("");
                    System.out.println("Supplier not found! - What do you want to do?");
                    System.out.println("(1)  Create and add new supplier to item");
                    System.out.println("(2)  Create new item without supplier");
                    System.out.println("(3)  Abort");
                    System.out.println("");
                    System.out.print("make choise: ");
                    int i = UIInput.inputInt();
            
                    if(i == 1)
                    {
                        createSupplier();
                        itemController.createItem(barcode, itemNumber, name, amountPrOrder, description, buyingPrice, sellingPrice, 
                                                  locationNumber, itemController.addSupplier(nameOfCreatedSupplier), amountInStock, minStock, maxStock);
                        System.out.println("");
                        System.out.println("Item created with new supplier");
                        back();            
                    }
                    if(i == 2)
                    {
                        itemController.createItem(barcode, itemNumber, name, amountPrOrder, description, buyingPrice, 
                                                  sellingPrice, locationNumber, null, amountInStock, minStock, maxStock);
                        System.out.println("");
                        System.out.println("Item created without supplier");
                        System.out.println("");
                        back();
                    }
                    if(i == 3)
                    {
                        writeMenu();
                    }
                }
            }
        }
    }
    
    /**
     * Create supplier
     */
    private void createSupplier()
    {
        System.out.print("Enter suppliers name: ");
        String nameSupplier = reader.nextLine();
        nameOfCreatedSupplier = nameSupplier;
        
        System.out.print("Enter suppliers address: ");
        String addressSupplier = reader.nextLine();
        
        System.out.print("Enter suppliers city: ");
        String citySupplier = reader.nextLine();
        
        System.out.print("Enter suppliers ZIPcode: ");
        int ZIPCodeSupplier = UIInput.inputInt();
        
        System.out.print("Enter suppliers phone number: ");
        int phoneNumberSupplier = UIInput.inputInt();
        
        System.out.print("Enter suppliers delivery time: ");
        String deliveryTimeSupplier = reader.nextLine();
        
        itemController.createSupplier(nameSupplier, addressSupplier, citySupplier, ZIPCodeSupplier, phoneNumberSupplier, deliveryTimeSupplier);
        
    }
    
    /**
     * Search for item by barcode.
     */
    private void findItemByBarcode()
    {
        System.out.print("Enter barcode: ");
        String barcode = reader.nextLine();
        if(itemController.findItemByBarcode(barcode) != null)
        {
            System.out.println("");
            System.out.println("Barcode:         " + itemController.findItemByBarcode(barcode).getBarcode());
            System.out.println("ItemNumber:      " + itemController.findItemByBarcode(barcode).getItemNumber());
            System.out.println("Name:            " + itemController.findItemByBarcode(barcode).getName());
            System.out.println("Discount:        " + itemController.findItemByBarcode(barcode).getDiscount());
            System.out.println("Amount pr order: " + itemController.findItemByBarcode(barcode).getAmountPrOrder());
            System.out.println("Description:     " + itemController.findItemByBarcode(barcode).getDescription());
            System.out.println("Buying Price:    " + itemController.findItemByBarcode(barcode).getBuyingPrice());
            System.out.println("Selling Price:   " + itemController.findItemByBarcode(barcode).getSellingPrice());
            System.out.println("Location Number: " + itemController.findItemByBarcode(barcode).getLocationsNumber());
            System.out.println("Amount in stock: " + itemController.findItemByBarcode(barcode).getAmountInStock());
            System.out.println("Minimum in stock: " + itemController.findItemByBarcode(barcode).getMinStock());
            System.out.println("Maximum in stock: " + itemController.findItemByBarcode(barcode).getMaxStock());
            if(itemController.findItemByBarcode(barcode).getSupplier() == null)
            {
                System.out.println("Supplier:        " + "NONE");
            }
            else
            {
                System.out.println("Suppler:         " + itemController.findItemByBarcode(barcode).getSupplier().getName());
            }
        }
        else
        {
            System.out.println("Barcode not found!");
        }
        back();
    }
    
    /**
     * Search for item by item number.
     */
    private void findItemByItemNumber()
    {
        System.out.print("Enter ItemNumber: ");
        String itemNumber = reader.nextLine();
        if(itemController.findItemByItemNumber(itemNumber) != null)
        {
            System.out.println("");
            System.out.println("Barcode:         " + itemController.findItemByItemNumber(itemNumber).getBarcode());
            System.out.println("ItemNumber:      " + itemController.findItemByItemNumber(itemNumber).getItemNumber());
            System.out.println("Name:            " + itemController.findItemByItemNumber(itemNumber).getName());
            System.out.println("Discount:        " + itemController.findItemByItemNumber(itemNumber).getDiscount());
            System.out.println("Amount pr order: " + itemController.findItemByItemNumber(itemNumber).getAmountPrOrder());
            System.out.println("Description:     " + itemController.findItemByItemNumber(itemNumber).getDescription());
            System.out.println("Buying Price:    " + itemController.findItemByItemNumber(itemNumber).getBuyingPrice());
            System.out.println("Selling Price:   " + itemController.findItemByItemNumber(itemNumber).getSellingPrice());
            System.out.println("Location Number: " + itemController.findItemByItemNumber(itemNumber).getLocationsNumber());
            System.out.println("Amount in stock: " + itemController.findItemByItemNumber(itemNumber).getAmountInStock());
            System.out.println("Minimum in stock: " + itemController.findItemByItemNumber(itemNumber).getMinStock());
            System.out.println("Maximum in stock: " + itemController.findItemByItemNumber(itemNumber).getMaxStock());
            if(itemController.findItemByItemNumber(itemNumber).getSupplier() == null)
            {
                System.out.println("Supplier:        " + "NONE");
            }
            else
            {
                System.out.println("Suppler:         " + itemController.findItemByItemNumber(itemNumber).getSupplier().getName());
            }
        }
        else
        {
            System.out.println("ItemNumber not found!");
        }
        back();
    }
    
    /**
     * Change something on an item.
     */
    private void updateItem()
    {
        System.out.print("Enter barcode: ");
        String barcode = reader.nextLine();
        if(itemController.findItemByBarcode(barcode) != null)
        {
            System.out.println("ItemNumber:      " + itemController.findItemByBarcode(barcode).getItemNumber());
            System.out.println("Name:            " + itemController.findItemByBarcode(barcode).getName());
            System.out.println("Discount:        " + itemController.findItemByBarcode(barcode).getDiscount());
            System.out.println("Amount pr order: " + itemController.findItemByBarcode(barcode).getAmountPrOrder());
            System.out.println("Description:     " + itemController.findItemByBarcode(barcode).getDescription());
            System.out.println("Buying Price:    " + itemController.findItemByBarcode(barcode).getBuyingPrice());
            System.out.println("Selling Price:   " + itemController.findItemByBarcode(barcode).getSellingPrice());
            System.out.println("Location Number: " + itemController.findItemByBarcode(barcode).getLocationsNumber());
            System.out.println("Supplier:        " + itemController.findItemByBarcode(barcode).getSupplier().getName());
            System.out.println("Amount in stock: " + itemController.findItemByBarcode(barcode).getAmountInStock());
            System.out.println("Minimum in stock: " + itemController.findItemByBarcode(barcode).getMinStock());
            System.out.println("Maximum in stock: " + itemController.findItemByBarcode(barcode).getMaxStock());
            System.out.println("");
            System.out.println("What do you want to update?");
            System.out.println("");
            System.out.println("(1)  Update discount");
            System.out.println("(2)  Update description");
            System.out.println("(3)  Update buy/sell prices");
            System.out.println("(4)  Update location");
            System.out.println("(5)  Update amount pr order");
            System.out.println("(6)  Update supplier");
            System.out.println("(7)  Update amount in stock");
            System.out.println("(8)  Update minimum in stock");
            System.out.println("(9)  Update maximum in stock");
            System.out.println("");
            System.out.print("make choise: ");
            
            int i = UIInput.inputInt();
            if(i ==1)
            {
                if(!loginName.equals("manager"))
                {
                    System.out.println("You dont have the rigths to do this!");
                }
                else
                {
                    System.out.print("New discount: ");
                    int discount = UIInput.inputInt();
                    itemController.updateItemDiscount(barcode, discount);
                    itemController.findItemByBarcode(barcode).setSellingPrice(itemController.findItemByBarcode(barcode).getSellingPrice()-discount);
                    System.out.println("Discount and selling price are updated");
                }
            }
            if(i ==2) 
            {
                System.out.print("New description: ");
                String description = reader.nextLine();
                description = reader.nextLine();
                itemController.updateItemDescription(barcode, description);
                System.out.println("Description updated");
            }
            if(i ==3) 
            {
                if(!loginName.equals("manager"))
                {
                    System.out.println("You dont have the rigths to do this!");
                }
                else
                {
                    System.out.print("New buying price: ");
                    int buyingPrice = UIInput.inputInt();
                    System.out.print("New selling price: ");
                    int sellingPrice = UIInput.inputInt();
                    itemController.updateItemBuySell(barcode, buyingPrice, sellingPrice);
                    System.out.println("Buy/Sell prices are updated");
                }
            }
            if(i ==4)
            {
                System.out.print("Enter location number. | 1: Byggecenter 2: Traelast 3: Both |: ");
                int locationNumberInt = UIInput.inputInt();
                if(locationNumberInt > 3 || locationNumberInt == 0)
                {
                    boolean ok = false;
                    while(!ok)
                    {
                        System.out.println("Wrong input, try again");
                        System.out.print("Enter location number. | 1: Byggecenter 2: Traelast 3: Both |: ");
                        int locationNumberInt2 = UIInput.inputInt();
                        if(locationNumberInt2 == 1 || locationNumberInt2 == 2 || locationNumberInt2 == 3)
                        {
                            locationNumberInt = locationNumberInt2;
                            ok = true;
                        }
                    }
                }
                
                String locationNumber = "";
                if(locationNumberInt == 1)
                {
                    locationNumber = "Byggecenter";
                }
                if(locationNumberInt == 2)
                {
                    locationNumber = "Traelast";
                }
                if(locationNumberInt == 3)
                {
                    locationNumber = "Byggecenter og traelast";
                }
                
                itemController.updateItemLocation(barcode, locationNumber);
                System.out.println("Location updated");
            }
            if(i ==5) 
            {
                System.out.print("New amount pr order: ");
                int amountPrOrder = UIInput.inputInt();
                itemController.updateAmountPrOrder(barcode, amountPrOrder);
                System.out.println("Amount pr order updated");
            }
            if(i ==6) 
            {
                System.out.print("New supplier: ");
                String name = reader.nextLine();
                name = reader.nextLine();
                
                try
                {
                    if(itemController.updateItemSupplier(name, barcode))
                    {
                        System.out.println("Supplier updated");
                    }
                }
                catch(Exception e)
                {
                    System.out.println(e.getMessage());
                }
            }
            if(i ==7) 
            {
                System.out.print("New amount in stock: ");
                int amountInStock = UIInput.inputInt();
                itemController.findItemByBarcode(barcode).setAmountInStock(amountInStock);
                System.out.println("Amount in stock updated");
            }
            if(i ==8) 
            {
                System.out.print("New minimum in stock: ");
                int minStock = UIInput.inputInt();
                itemController.findItemByBarcode(barcode).setMinStock(minStock);
                System.out.println("Minimum amount in stock updated");
            }
            if(i ==9) 
            {
                System.out.print("New maximum in stock: ");
                int maxStock = UIInput.inputInt();
                itemController.findItemByBarcode(barcode).setMaxStock(maxStock);
                System.out.println("Maximum in stock updated");
            }
        }
        else
        {
            System.out.println("Barcode does not exist!");
        }
        back();
    }
    
    /**
     * Deletes an item.
     */
    private void deleteItem()
    {
        if(!loginName.equals("manager"))
        {
            System.out.println("You dont have the rigths to do this!");
            back();
        }
        else
        {
        
            System.out.print("Enter barcode on item you want to delete: ");
            String barcode = reader.nextLine();
        
            if(itemController.deleteItem(barcode))
            {
                System.out.println("Barcode deleted: " + barcode);
            }
            else
            {
                System.out.println("Error - Not deleted");
            }
            back();
        }
    }
    
    /**
     * Used to create a list of items where you can chose different locations.
     */
    private void listOfItems()
    {
        System.out.print("What location? (1: Byggecenter 2: Traelast 3: Byggecenter and traelast): ");
        int location = UIInput.inputInt();
        if(location == 1)
        {
            int index = listOfItemsForLocation("Byggecenter");
            System.out.println("Total items in Byggecenter: " + index);
        }
        else if(location == 2)
        {
            int index = listOfItemsForLocation("Traelast");
            System.out.println("Total items in Traelast: " + index);
        }
        else if(location == 3)
        {
            int index = listOfItemsForLocation("Byggecenter and traelast");
            System.out.println("Total items which are in Byggecenter and traelast at the same time: " + index);
        }
        else
        {
            System.out.print("Nothing is chosen - try again.");
        }
        back();
    }
    
    /**
     * Used to create a list of items where you can chose different locations.
     * @param location Is recieved from the method listOfItems
     * @return index Used to calculate how many items there are on the chosen location
     */
    private int listOfItemsForLocation(String location)
    {
        int index = 0;
        for(String barcode : itemController.listOfItems())
        {
            if(itemController.findItemByBarcode(barcode).getLocationsNumber().equals(location))
            {
                System.out.println("Barcode:         " + itemController.findItemByBarcode(barcode).getBarcode());
                System.out.println("Item nb:         " + itemController.findItemByBarcode(barcode).getItemNumber());
                System.out.println("Name:            " + itemController.findItemByBarcode(barcode).getName());
                System.out.println("Discount:        " + itemController.findItemByBarcode(barcode).getDiscount());
                System.out.println("Amount pr order: " + itemController.findItemByBarcode(barcode).getAmountPrOrder());
                System.out.println("Description:     " + itemController.findItemByBarcode(barcode).getDescription());
                System.out.println("Buying price:    " + itemController.findItemByBarcode(barcode).getBuyingPrice());
                System.out.println("Selling price:   " + itemController.findItemByBarcode(barcode).getSellingPrice());
                System.out.println("Location nb:     " + itemController.findItemByBarcode(barcode).getLocationsNumber());
                System.out.println("Amount in stock: " + itemController.findItemByBarcode(barcode).getAmountInStock());
                System.out.println("Minimum stock:   " + itemController.findItemByBarcode(barcode).getMinStock());
                System.out.println("Maximum stock:   " + itemController.findItemByBarcode(barcode).getMaxStock());
                if(itemController.findItemByBarcode(barcode).getSupplier() == null)
                {
                    System.out.println("Supplier:        " + "NONE");
                }
                else
                {
                    System.out.println("Suppler:         " + itemController.findItemByBarcode(barcode).getSupplier().getName());
                }
                System.out.println("");
                index++;
            }
        }
        return index;
    }
    
    /**
     * Wait.
     */
    private void back()
    {
        System.out.println("");
        System.out.print("Press 'enter' to get back to menu");
        String i = reader.nextLine();
    }
    
    /**
     * Items which have to be ordered by supplier.
     */
    private void itemsToOrderBySupplier()
    {
        System.out.println("- Items which have been ordered -");
        boolean itemsOrdered = false;
            
        for(String barcode : itemController.listOfItems())
        {
            if (itemController.findItemByBarcode(barcode).getOrderedBySupplier() == true)
            {
                System.out.println("Barcode:         " + itemController.findItemByBarcode(barcode).getBarcode());
                System.out.println("Item nb:         " + itemController.findItemByBarcode(barcode).getItemNumber());
                System.out.println("Name:            " + itemController.findItemByBarcode(barcode).getName());
                System.out.println("Amount in stock: " + itemController.findItemByBarcode(barcode).getAmountInStock());
                System.out.println("Amount pr order: " + itemController.findItemByBarcode(barcode).getAmountPrOrder());
                System.out.println("Minimum stock:   " + itemController.findItemByBarcode(barcode).getMinStock());
                System.out.println("Maximum stock:   " + itemController.findItemByBarcode(barcode).getMaxStock());
                System.out.println("");
                if(!itemsOrdered)
                {
                    itemsOrdered = true;
                }
            }
        }
        if(!itemsOrdered)
        {
             System.out.println("No items have been ordered");
             System.out.println("");
        }
        
        System.out.println("- Items which you have to order -");
        if(!itemController.itemsToOrderBySupplier().isEmpty())
        {
            for(String barcode : itemController.itemsToOrderBySupplier())
            {
                System.out.println("Barcode:         " + itemController.findItemByBarcode(barcode).getBarcode());
                System.out.println("Item nb:         " + itemController.findItemByBarcode(barcode).getItemNumber());
                System.out.println("Name:            " + itemController.findItemByBarcode(barcode).getName());
                System.out.println("Amount in stock: " + itemController.findItemByBarcode(barcode).getAmountInStock());
                System.out.println("Amount pr order: " + itemController.findItemByBarcode(barcode).getAmountPrOrder());
                System.out.println("Minimum stock:   " + itemController.findItemByBarcode(barcode).getMinStock());
                System.out.println("Maximum stock:   " + itemController.findItemByBarcode(barcode).getMaxStock());
                System.out.println("");
                System.out.println("How many do you want to order? ");
                System.out.print("(amount) x " + itemController.findItemByBarcode(barcode).getAmountPrOrder() + " unit(s). Enter amount: ");
                int amountToOrder = UIInput.inputInt();
                int totalAmountToOrder = amountToOrder * itemController.findItemByBarcode(barcode).getAmountPrOrder();
                System.out.println("");
                System.out.println("Total units you want to order: " + totalAmountToOrder);
                if(totalAmountToOrder > itemController.findItemByBarcode(barcode).getMaxStock() - itemController.findItemByBarcode(barcode).getAmountInStock())
                {
                    boolean ok = false;
                    while(!ok)
                    {
                        System.out.println("");
                        System.out.println("You order is to big. You can maksimum order " + (itemController.findItemByBarcode(barcode).getMaxStock() - itemController.findItemByBarcode(barcode).getAmountInStock())+ " unit(s)");
                        System.out.print("(amount) x " + itemController.findItemByBarcode(barcode).getAmountPrOrder() + " unit(s). Enter amount:");
                        int amountToOrder2 = UIInput.inputInt();
                        int totalAmountToOrder2 = amountToOrder2 * itemController.findItemByBarcode(barcode).getAmountPrOrder();
                        if(totalAmountToOrder2 < itemController.findItemByBarcode(barcode).getMaxStock() - itemController.findItemByBarcode(barcode).getAmountInStock())
                        {
                            totalAmountToOrder = totalAmountToOrder2;
                            ok = true;
                        }
                    }
                }
                System.out.println("Order OK - Sent to supplier");
                itemController.findItemByBarcode(barcode).setOrderedBySupplier(true);
                System.out.println("");
            }
        }
        else
        {
            System.out.println("No items have to be ordered");    
        }
        back();
    }
    
    /**
     * Updates stock when a new delivery arrives.
     */
    private void updateStockNewDelivery0()
    {
        System.out.print("Enter barcode: ");
        String barcode = reader.nextLine();
        
        if(itemController.findItemByBarcode(barcode) != null)
        {
            System.out.println("Name: " + itemController.findItemByBarcode(barcode).getName());
            System.out.println("");
            System.out.print("Enter amount delivered: ");
            int amountDelivered = UIInput.inputInt();
        
            itemController.updateStockNewDelivery(barcode, amountDelivered);
            System.out.println("Updated - new amount: " + itemController.findItemByBarcode(barcode).getAmountInStock());
            System.out.println("");
        }
        else
        {
            System.out.println("Barcode not found - you may have to create a new item with this barcode");
            System.out.println("");
        }
    }
    
    /**
     * Menu where the user can chose between update and exit.
     */
    private void updateStockNewDelivery()
    {
        boolean stop = false;
        while(!stop) {
            System.out.println("Update press 1 | Exit press 0");
            int i = UIInput.inputInt();
            if(i == 1) 
            {
                updateStockNewDelivery0();
            }
            if(i == 0) 
            {
                stop = true;
            }
        }
    }
}